import { SendMsgTemplate } from "./Entity/SendMsgTemplate/SendMsgTemplate";
import { GlobalQueue } from "./Entity/Common/Global";
import { Request } from "./Entity/Common/Request";


 /** 消息处理 */

 export class Queue 
 {
    Push(model:SendMsgTemplate,callback:Function = null,error:Function = null)
    {
        if (!model.ClientToken) {
            console.error("model ClientToken is null");
            return;
        }

        if (!model.Template) {
            console.error("model Template is null");
            return;
        }

        if (!model.MessageKey) {
            console.error("model MessageKey is null");
            return;
        }

        if (!model.Content) {
            console.error("model Content is null");
            return;
        }

        var request = new Request(GlobalQueue.QueuePlus.toString(),model);


        request.Then(function(e){
            callback && callback(e);
        }).Catch(function(e){ 
            error(e); 
        }).Post();
    } 

 }